class Solution:
    def canJump(self, nums) -> bool:
        max_tar, flag_nums = 0, len(nums)-1
        for index, num in enumerate(nums):
            if index == flag_nums:
                return True
            if num > 0:
                max_tar = max(index + num, max_tar)
            else:
                if max_tar <= index:
                    return False


a = Solution()
print(a.canJump([3,2,1,0,4]))